class · System.Threading.Tasks

Task<T>

public class Task<T> : Task

A task with a value: what an async function that returns one gives.

Tipo
class
Espacio de nombres
System.Threading.Tasks
Ensamblado
System.Core
Acceso
public
Archivo fuente
Tasks.ant

Parámetros de tipo

NombreRestricciones
Tcualquier tipo

Herencia

Clases base
Any Task Task<T>

Propiedades

T Result { get; }
#

read-only

The value, once done (runs the scheduler until then; throws the error if it failed).

Métodos

SetResult(T value)
#

Done with value.

GetResult() : T
#

What await gives once the task has finished: its value (or its error, thrown).

static FromResult(T value) : Task<T>
#

static

A task done with value.

Campos

T result
#

inherited

Miembros heredados (24)

Código fuente

Task<T> en Antril, descompilado a partir de su Larva HIR.

System.Threading.Tasks.Task`1.ant
// System.Threading.Tasks.Task — System.Core (decompiled from Larva HIR)

into namespace System.Threading.Tasks
{
	/// A task with a value: what an async function that returns one gives.
	public class Task<T> : Task
	{
		inherited:
			T result;

		public:
			/// Done with `value`.
			SetResult(T value)
			{
				result = value;
				Complete();
			}

			/// What `await` gives once the task has finished: its value (or its error, thrown).
			GetResult() : T
			{
				Check();
				return result;
			}

			/// A task done with `value`.
			static FromResult(T value) : Task<T>
			{
				Task<T> task = new Task<T>();
				task.SetResult(value);
				return task;
			}

			/// The value, once done (runs the scheduler until then; throws the error if it failed).
			T Result
			{
				get
				{
					Wait();
					return result;
				}
			}
	}
}
Esc